package com.boot.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.boot.entity.SysUser;
import com.boot.mapper.SysUserMapper;
import com.boot.service.ISysUserService;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 用户表 服务实现类
 * </p>
 *
 * @author bbyh
 * @since 2025-09-23
 */
@Service
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements ISysUserService {
    @Override
    public void updateWithoutPassword(SysUser user) {
        LambdaUpdateWrapper<SysUser> wrapper = new LambdaUpdateWrapper<>();
        wrapper.eq(SysUser::getId, user.getId());
        if (user.getUsername() != null) wrapper.set(SysUser::getUsername, user.getUsername());
        if (user.getRealName() != null) wrapper.set(SysUser::getRealName, user.getRealName());
        if (user.getPhone() != null) wrapper.set(SysUser::getPhone, user.getPhone());
        if (user.getEmail() != null) wrapper.set(SysUser::getEmail, user.getEmail());
        if (user.getEnabled() != null) wrapper.set(SysUser::getEnabled, user.getEnabled());
        this.update(wrapper);
    }
}
